home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nikkei Mac 20
/
NIKKEI-MAC-CD-VOL-20-1998-12.ISO.7z
/
NIKKEI-MAC-CD-VOL-20-1998-12.ISO
/
オンラインソフト
/
5.文書作成支援
/
UltraFind
/
UltraFind 2.5.3 Full Pack.sit
/
UltraFind 2.5.3 Full Package
/
AppleScript™ Examples
/
UF Find Text
< prev
next >
Wrap
Text File
|
1997-06-21
|
4KB
|
86 lines
set numFiles to 0
tell application "UltraFind 2.5.3"
clear
set the text of fileName of its searchRoutine to "read me"
set the searchType of fileName of its searchRoutine to nameIs
set the text of targetWord 1 of searchText of its searchRoutine to "apple"
set the text of targetWord 2 of searchText of its searchRoutine to "version"
set the text of targetWord 3 of searchText of its searchRoutine to "project"
--the following scripts are commented out and are included only as examples:
-- example of how to use UltraFind's Thesaurus:
-- set the XRef of targetWord 1 of searchText of its searchRoutine to XRefON
-- use this to find only those files which contain both target words:
-- set options of searchText of its searchRoutine to matchAll
-- use this only if you want to search ALL types of files (including graphics images, application, etc.
-- without this only documents likely to contain text will be searched:
-- set options of searchText of its searchRoutine to searchAll
-- use this only if you want to search the files' resource forks:
-- set options of searchText of its searchRoutine to searchResources
-- you may want to search only those files in a specific directory, e.g.:
-- set the confineDirectory of its searchRoutine to "Hard Disk:Text Files"
--set the maximum number of found words to show, e.g. 3
set showWords of searchText of its searchRoutine to 1
scan
changeView finderView --make sure the list window is in FINDER VIEW to process the text found
copy the result to numFiles
end tell
if numFiles is greater than 0 then
--process the list in TEXT VIEW to get individual words and offsets
tell application "UltraFind 2.5.3" to changeView textView
copy the result to numRecords
set recNum to 1
set fileNum to 1
set dialogtext to ""
repeat until recNum is greater than numRecords
tell application "UltraFind 2.5.3"
copy (the fileName of fileRecord recNum) to fName
copy (the textFound of fileRecord recNum) to fText
copy (the textOffset of fileRecord recNum) to fOffset
end tell
set recNum to recNum + 1
--in TEXT view each file found has one MASTER record and one or more TEXT records
--the MASTER record returns a list of all the words found but has no textoffset
--the TEXT record returns the words found and its location (textoffset) in characters from the start of the file
if fOffset is equal to "" then --its a master record
--check if previous file's results dialog needs to be displayed
if dialogtext is not equal to "" then
set dialogtext to dialogtext & return
display dialog dialogtext buttons {"Cancel", "Next"} default button 2
end if
set dialogtext to "Found file " & (fileNum as text) & " of " & (numFiles as text) & return & return & ツ
"Text Search Results for File '" & fName & "' :" & return & return
set fileNum to fileNum + 1
else
set dialogtext to dialogtext & "At offset " & fOffset & " found '" & fText & "'" & return
end if
end repeat
--repeat with fileNum from 1 to numFiles
-- tell application "UltraFind"
-- copy (the fileName of fileRecord fileNum) to fName
-- copy (the textFound of fileRecord fileNum) to fText
-- end tell
-- display dialog "Found file " & (fileNum as text) & " of " & (numFiles as text) & return & return & ツ
-- "Filename : " & fName & return & ツ
-- "Found words: '" & fText & "'" & return & return ツ
-- buttons {"Cancel", "Next"} default button 2
--end repeat
end if
end if